# Maintainer: Chloe Kudryavtsev <toast@toastin.space>
pkgname=rclone
pkgver=1.51.0
pkgrel=1
pkgdesc="Rsync for cloud storage"
url="https://rclone.org/"
arch="all"
license="MIT"
makedepends="binutils-gold go"
options="net"
source="rclone-$pkgver.tar.gz::https://github.com/ncw/rclone/archive/v$pkgver.tar.gz"
subpackages="$pkgname-doc"

export GO111MODULE=on
export GOPATH="$srcdir"
export CGO_ENABLED=0

build() {
	go build
}

check() {
	# backend/{ftp,sftp,swift,webdav}: uses docker(1) for tests
	# backend/{local,memory}: fails in docker envs, but not on real machines
	# fs/rc: fails on ppc64le
	go test $(go list ./... | grep -v \
		-e 'backend/ftp$' \
		-e 'backend/local$' \
		-e 'backend/memory$' \
		-e 'backend/sftp$' \
		-e 'backend/swift$' \
		-e 'backend/webdav$' \
		-e 'fs/rc$'
		)
}

package() {
	install -Dm755 "$builddir"/"$pkgname" \
		"$pkgdir"/usr/bin/"$pkgname"

	install -Dm644 "$builddir"/"$pkgname".1 \
		"$pkgdir"/usr/share/man/man1/"$pkgname".1
}

cleanup_srcdir() {
	go clean -modcache
	default_cleanup_srcdir
}

sha512sums="b0881e09b75093abe4d31e95425a90513aed4a16d9e2dbf79023c9dc68875b90a1332204879530c450a16ab9cac475d967f7657d6f810a1e0f0d84b88d7de916  rclone-1.51.0.tar.gz"
